<!Doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>大旺福--{$title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/assets/layui/css/global.css" media="all">
    <link rel="stylesheet" href="/assets/layui/css/admin.css" media="all">
    <style>
        .pre-seckill-item .layui-form-checkbox{
            margin-bottom: 5px;
        }
    </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">

    <!-- header start -->
    {include file="layout/header.html"}
    <!-- header end -->

    <!-- nav start-->
    {include file="layout/nav.html"}
    <!-- nav end-->

    <!-- main start -->
    <div class="layui-body site-demo">
        <div class="layui-main">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>{$title}</legend>
            </fieldset>
            <div class="site-block">
                <div class="searchbar">
                    <form action="#" method="get" class="layui-form search-from">
                        <input type="hidden" name="search_list" value='{$search_array_str}'/>
                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <select class="auto" name="search[shop_id]">
                                    <option value="">选择供应商</option>
                                    {foreach from=$shop item=one}
                                    <option value="{$one.id}" {if $search_array.shop_id eq $one.id}selected{/if}>{$one.shop_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[shelf]">
                                    {if $search_array.shelf eq ''}
                                    <option value="" selected>选择上下架</option>
                                    <option value="1">上架</option>
                                    <option value="0">下架</option>
                                    {else}
                                    <option value="">选择上下架</option>
                                    <option value="1" {if $search_array.shelf eq 1}selected{/if}>上架</option>
                                    <option value="0" {if $search_array.shelf eq 0}selected{/if}>下架</option>
                                    {/if}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[seckill]">
                                    {if $search_array.seckill eq ''}
                                    <option value="">选择是否秒杀</option>
                                    <option value="0">非秒杀</option>
                                    <option value="1">秒杀</option>
                                    {else}
                                    <option value="">选择状态</option>
                                    <option value="0" {if $search_array.seckill eq 0}selected{/if}>非秒杀</option>
                                    <option value="1" {if $search_array.seckill eq 1}selected{/if}>秒杀</option>
                                    {/if}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[name]">
                                    <option value="name" {if $search_array.name eq 'name'} selected{/if}>商品名</option>
                                    <option value="goods_no" {if $search_array.name eq 'goods_no'} selected{/if}>商品货号</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="search[keywords]"  autocomplete="off" class="layui-input" value="{$search_array.keywords}">
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[stock]">
                                    {if $search_array.stock eq ''}
                                    <option value="" selected>选择备货</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                    {else}
                                    <option value="">选择备货</option>
                                    <option value="1" {if $search_array.stock eq 1}selected{/if}>是</option>
                                    <option value="0" {if $search_array.stock eq 0}selected{/if}>否</option>
                                    {/if}
                                </select>
                            </div>
                            <div class="layui-input-inline button-warp">
                                <input type="hidden" name="search[categroy_select_id]" value="">
                                <button type="button" class="layui-btn layui-btn-warm layui-btn-small category-select" style="margin-top:5px;"><i class="layui-icon">&#xe608;</i> <span>选择分类</span></button>
                            </div>
                            <div class="layui-input-inline button-warp">
                                <button type="button" class="layui-btn layui-btn-small search-button" style="margin-top:5px;"><i class="layui-icon">&#xe615;</i> <span>筛选</span></button>
                            </div>
                            <div class="layui-input-inline button-warp">
                                <button type="button" class="layui-btn layui-btn-small offline-button" style="margin-top:5px;"><i class="layui-icon">&#xe60f;</i> <span>一键下线</span></button>
                            </div>
                        </div>
                        <!--<button class="btn" onclick="changeAction(true)"><span class="sel">导出Excel</span></button>-->
                    </form>
                </div>
                <hr />
                {if $preSeckillProducts|@count > 0}
                <form action="#" class="layui-form no-margin">
                    <lable class="layui-form-label">预上线商品</lable>
                    <div class="layui-input-block pre-seckill-item">
                        {foreach from=$preSeckillProducts item=pre}
                            <input type="checkbox" name="pre" title="{$pre.product_name}[{$pre.sku_name}]" data-id="{$pre.id}" data-pid="{$pre.product_id}"  data-gid="{$pre.goods_id}">
                        {/foreach}
                        <div class="button-warp">
                        <button type="button" class="layui-btn" id="pre-seckill">确认</button>
                        </div>
                    </div>
                </form>
                <hr />
                {/if}
                <div class="content">
                    <form action="#" method="get" class="layui-form no-margin">
                        <table class="layui-table" lay-even>
                            <colgroup>
                                <col width="50">
                                <col width="250">
                                <col>
                            </colgroup>
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>商品名称</th>
                                <th>详情</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach from=$products item=product}
                            <tr class="sel pro_{$product.id}">
                                <td>{$product.id}</td>
                                <td>
                                    {$product.product_name}<br>
                                    {foreach from=$product.category item=categoty}[{$categoty.category_name}]{/foreach}
                                </td>
                                <td>
                                    <table class="layui-table goods_{$product.id}" lay-skin="nob">
                                        <colgroup>
                                            <col width="100">
                                            <col width="50">
                                            <col width="50">
                                            <col width="50">
                                            <col width="50">
                                        </colgroup>
                                        <thead>
                                        <tr>
                                            <td>规格(价格)</td>
                                            <td>库存(虚/实)</td>
                                            <td>秒杀价格</td>
                                            <td>秒杀库存</td>
                                            <td>秒杀</td>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {foreach from=$product.goodsList item=goods}
                                        <tr class="sku_{$goods.id}">
                                            <td>
                                                {if $goods.spec_array|count eq 0}
                                                    默认
                                                {else}
                                                    {foreach from=$goods.spec_array item=sku}
                                                        {$sku.value}
                                                    {/foreach}
                                                {/if}
                                                / ￥{$goods.sell_price}
                                            </td>
                                            <td>{$goods.store_nums} / {$goods.store_nums_real}</td>
                                            <td>
                                                <div class="layui-input-inline">
                                                    <input type="tel" name="seckill_price" class="layui-input seckill-input seckill-price" data-pid="{$product.id}" data-gid="{$goods.id}" value="{$goods.seckill_detail.sell_price}">
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-input-inline">
                                                    <input type="tel" name="seckill_nums" class="layui-input seckill-input seckill-store" data-pid="{$product.id}" data-gid="{$goods.id}" data-origin="{$goods.seckill_detail.store_nums}-{$goods.seckill_detail.store_nums_real}" value="{$goods.seckill_detail.store}">
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-input-inline">
                                                    <input type="checkbox" name="seckill" data-pid="{$product.id}" data-gid="{$goods.id}" lay-filter="seckill" lay-skin="switch" lay-text="是|否" {if $goods.seckill == 1}checked{/if}>
                                                </div>
                                            </td>
                                        </tr>
                                        {/foreach}
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </form>
                </div>
                <div class="layui-box layui-laypage layui-laypage-default">
                    {$pageStr}
                    <span>当前第{$currentPage}页/共{$totalPage}页</span>
                </div>
            </div>

        </div>
    </div>
    <!-- main end -->

</div>
<div id="category-content" style="display: none;">
    <input type="hidden" name="categroy_id" value="0">
    <button type="button" class="layui-btn layui-btn-warm layui-btn-small add-category layui-hide" style="margin-top:5px;"><i class="layui-icon">&#xe608;</i> <span>选择分类</span></button>
    <div class="category-list layui-clear site-block" style="padding:10px;">
        <ul id="category-tree" class="layui-box layui-tree" style="margin-bottom:10px;"></ul>
    </div>
</div>
<!--库存更新模板-->
{literal}
<script id="goodsStoreTemplate" type="text/html">
    <div class="quickEditForm-content">
        <form name="quickEditForm">
            <table class="border_table" style="width:100%">
                <thead>
                <tr>
                    <th>商品</th>
                    <th>库存量</th>
                </tr>
                </thead>
                <tbody>
                {{# layui.each(d.list, function(index, item){ }}
                <tr>
                    <td>
                        {{item.product_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# if(item['spec_array']){ }}
                        {{# layui.each(item['spec_array'], function(i, e){ }}
                        {{e.name}}:{{e.value.value_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# })}}
                        {{# } }}
                    </td>
                    <td>
                        <input type="text" class="small" name="data[{{item['id']}}]" value="{{item['store_nums']}}" />
                    </td>
                </tr>
                {{# }) }}
                </tbody>
            </table>
            <input type='hidden' name='product_id' value="{{d.productId}}" />
        </form>
    </div>
</script>
<!--价格更新的模板-->
<script id="goodsPriceTemplate" type="text/html">
    <div class="quickEditForm-content">
        <form name="quickEditForm">
            <table class="border_table" style="width:100%">
                <thead>
                <tr>
                    <th>商品</th>
                    <th>市场价</th>
                    <th>销售价</th>
                    <th>成本价</th>
                    <th>返现金额</th>
                    <th>商家分成金额</th>
                    <th>区域经理分成金额</th>
                </tr>
                </thead>
                <tbody>
                {{# layui.each(d.list, function(index, item){ }}
                <tr>
                    <td>
                        {{item.product_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# if(item['spec_array']){ }}
                        {{# layui.each(item['spec_array'], function(i, e){ }}
                        {{e.name}}:{{e.value.value_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# }) }}
                        {{# } }}
                    </td>
                    <td><input type="text" class="small" name="data[{{item.id}}][market_price]" value="{{item['market_price']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][sell_price]" value="{{item['sell_price']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][cost_price]" value="{{item['cost_price']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][cash_back]" value="{{item['cash_back']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][proportion]" value="{{item['proportion']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][area_proportion]" value="{{item['area_proportion']}}" /></td>
                </tr>
                {{# }) }}
                </tbody>
            </table>
            <input type='hidden' name='product_id' value="{{d.productId}}" />
        </form>
    </div>
</script>
{/literal}
{include file="layout/footerJs.html"}
<script src="/assets/layui/js/product/product_list.js"></script>
<script src="/assets/layui/js/product/product_seckill.js"></script>
</body>
</html>